﻿using System;
using System.Windows.Media;
using MVVM_CAD.Common;

namespace MVVM_CAD.Model
{
    public class Line : FigureBase 
    {
        public Line() : base("Line")
        {
        }



        public override void Draw(DrawingContext drawingContext)
        {
            if (drawingContext == null)
            {
                throw new ArgumentNullException("drawingContext");
            }

            var brush = new SolidColorBrush(ObjectColor);
            PointsCollection.ForEach(p => drawingContext.DrawRectangle(brush, 
                                                                       new Pen(), 
                                                                       new System.Windows.Rect(p.X, p.Y, LineWidth, LineWidth)));

            base.Draw(drawingContext);
        }

        public override int HandleCount
        {
            get { return 2; }
        }

        public override bool Contains(IPoint point)
        {
            return PointsCollection.Contains(point);
        }

        public override IPoint GetHandle(int handleNumber)
        {
            if (handleNumber == 1)
                return InitialPoint;
            else
                return FinalPoint;
        }

        public override void Move(double deltaX, double deltaY)
        {
            throw new System.NotImplementedException();
        }

        public override void MoveHandleTo(IPoint point, int handleNumber)
        {
            throw new System.NotImplementedException();
        }

        public override System.Windows.Input.Cursor GetHandleCursor(int handleNumber)
        {
            throw new System.NotImplementedException();
        }
    }
}
